#!/bin/bash

# 物联网设备管理平台 - 启动脚本 (Linux/Mac)

set -e

echo "========================================"
echo "物联网设备管理平台 - 启动脚本"
echo "========================================"
echo ""

# 检查Docker
echo "[1/3] 检查Docker是否运行..."
if ! docker version &> /dev/null; then
    echo "[错误] Docker未运行，请先启动Docker"
    exit 1
fi
echo "[成功] Docker已运行"

# 启动服务
echo ""
echo "[2/3] 启动所有服务..."
docker-compose up -d

# 等待服务启动
echo ""
echo "[3/3] 等待服务启动..."
sleep 10

# 检查服务状态
echo ""
echo "服务状态:"
docker-compose ps

echo ""
echo "========================================"
echo "服务启动完成！"
echo "========================================"
echo ""
echo "访问地址:"
echo "  前端界面: http://localhost:3000"
echo "  后端API:  http://localhost:5000"
echo "  EMQX管理: http://localhost:18083 (admin/public)"
echo ""
echo "查看日志:"
echo "  docker-compose logs -f"
echo ""
echo "停止服务:"
echo "  docker-compose down"
echo ""
echo "========================================"

